const logger = require('./logger');
const NotifyClient = require('@up/notify-client');

const notifyClient = new NotifyClient('CrawlManagerWebServer');
// 企业微信告警
function send(subject, content) {
    const { toUser, type } = global.CONFIG.notify || {};
    subject = `[CrawlManagerWebServer]${subject}`;

    if (toUser && type) {
        notifyClient.send(toUser, subject, content, type).then(() => {
            console.log('notifyHelper.send suc');
        }).catch((e) => {
            logger.error.error('notifyHelper.send err.', e);
        });
    }
}

const notifyHelper = {
    send
};

module.exports = notifyHelper;
